package com.zhanglinwei.openApiServer.controller;

import com.zhanglinwei.common.Response;
import com.zhanglinwei.openApiClient.wrapper.OpenApiLambdaWrapper;
import com.zhanglinwei.openApiServer.service.OpenApiService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/openapi")
public class OpenApiController {

    @Resource
    private OpenApiService openApiService;

    @PostMapping("/lambda/wrapper")
    public Response<?> lambdaWrapperQuery(@RequestBody OpenApiLambdaWrapper<?> lambdaWrapper) {
        return Response.success(openApiService.lambdaWrapperQuery(lambdaWrapper));
    }

    @PostMapping("/apiCode/{apiCode}/{apiVersion}")
    public Response<?> apiCodeQuery(@PathVariable("apiCode") String apiCode, @PathVariable("apiVersion") String apiVersion, @RequestBody Map<String, Object> paramMap) {
        return Response.success(openApiService.apiCodeQuery(apiCode, apiVersion, paramMap));
    }

}
